package org.lewis.common.interceptors;

import org.apache.commons.lang.StringUtils;
import org.lewis.common.utils.VmUtils;

import com.tocersoft.framework.core.annotations.Component;
import com.tocersoft.framework.core.utils.PropertiesUtils;
import com.tocersoft.framework.web.Execution;
import com.tocersoft.framework.web.HttpUtils;
import com.tocersoft.framework.web.WebUtils;
import com.tocersoft.framework.web.annotations.InterceptorOrder;
import com.tocersoft.framework.web.interceptors.Interceptor;
import com.tocersoft.framework.web.interceptors.InterceptorChain;

@Component
@InterceptorOrder(1)
public class DataInterceptor implements Interceptor {
	

	public void intercept(Execution execution, InterceptorChain chain)
			throws Exception {
		WebUtils.getRequest().setAttribute("VM", new VmUtils());
		//静态服务器配置
		String staticWeb=PropertiesUtils.getValue("static.web.app");
		if(StringUtils.isEmpty(staticWeb)){
			staticWeb=HttpUtils.getContentPath();
		}
		WebUtils.getSession().setAttribute("staticWeb",staticWeb);
		
		//歌曲存储服务器
		String songWeb=PropertiesUtils.getValue("song.web.app");
		WebUtils.getSession().setAttribute("songWeb",songWeb);
		
		chain.doInterceptor(execution);
	}
}
